package JET.physics;

import JET.geom.Vec2d;

/**
 *
 * @author 057Ry
 */
public abstract class BoundingArea
{
    public abstract double getWidth();
    public abstract double getHeight();

    public abstract double getMinX();
    public abstract double getMinY();
    public abstract double getMaxX();
    public abstract double getMaxY();

    public Vec2d getCornerUpperLeft() {
        return new Vec2d(getMinX(), getMaxY());
    }
    public Vec2d getCornerUpperRight() {
        return new Vec2d(getMaxX(), getMaxY());
    }
    public Vec2d getCornerLowerRight() {
        return new Vec2d(getMaxX(), getMinY());
    }
    public Vec2d getCornerLowerLeft() {
        return new Vec2d(getMinX(), getMinY());
    }

    public abstract void setMinX(double x);
    public abstract void setMinY(double y);
    public abstract void setMaxX(double x);
    public abstract void setMaxY(double y);

    public abstract double getMaxDimension();
    public abstract boolean intersectsWith(BoundingArea ba);
    public abstract boolean contains(Vec2d vec);
    public abstract void extendToContain(Vec2d v);

    public void reset() {
        setMaxX(Double.NEGATIVE_INFINITY);
        setMaxY(Double.NEGATIVE_INFINITY);
        setMinX(Double.POSITIVE_INFINITY);
        setMinY(Double.POSITIVE_INFINITY);
    }

    public String toString()
    {
        return "BoundingArea ["+getCornerLowerLeft()+"] ["+getCornerUpperRight()+"]";
    }
}
